package com.hyt.it.ogt.kq.common.bm.config.deserializable;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.hyt.it.ogt.kq.common.bm.config.JacksonConfig;

import java.io.IOException;
import java.util.Date;

/**
 * @program: it-ogt-bm
 * @description: 国际化跨时区问题兼容适配（2022-05-23T00:00:00.000+0800）
 * @author: Yang HuanKun
 * @create: 2022-05-23 15:07
 **/
public class DateDeserializer extends JsonDeserializer<Date> {
    @Override
    public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        String date = p.getText();
        return DateUtil.parse(date, JacksonConfig.DEFAULT_DATE_FORMAT);
    }
}
